import type {
  AddressItem,
  Logistics,
  OrderDetail,
  OrderPre
} from '@/types/order'
import { request } from '@/utils/request'

// 药品处方信息 预支付
export const getMedicalOrderPre = (params: { prescriptionId: string }) => {
  return request<OrderPre>('/patient/medicine/order/pre', 'GET', params)
}

// 收货地址
export const getAddressList = () => {
  return request<AddressItem[]>('/patient/order/address', 'GET')
}

// 药品订单
export const createMedicalOrder = (data: {
  id: string
  couponId?: string
  addressId: string
}) => {
  return request<{ id: string }>('/patient/medicine/order', 'POST', data)
}

// 药品订单详情
export const getMedicalOrderDetail = (id: string) => {
  return request<OrderDetail>(`/patient/medicine/order/detail/${id}`, 'GET')
}

// 物流详情
export const getMedicalOrderLogisticsDetail = (id: string) => {
  return request<Logistics>(`/patient/order/${id}/logistics`, 'GET')
}
